package org.campuscontent.main;

import java.util.Locale;

import javax.swing.JApplet;

import org.campuscontent.config.languages.LanguageManager;

public class AutomataApplet extends JApplet
{
    private MainFrame mf;

    public void init()
    {
        // System.setProperty( "org.campuscontent.persistence.debug", "true" );
        mf = new MainFrame( this );
        // mf.userType = new String
        // (Base64.decode(this.getParameter("userType")));
        // mf.model = new String (Base64.decode(this.getParameter("model")));

        try
        {
            mf.userid   = this.getParameter( "userid" );
            mf.loidMain = this.getParameter( "loid"   );
            
//            System.out.println( "userid = " + mf.userid + "   loid= " + mf.loidMain );
            
            mf.init();
        }
        catch ( Exception e )
        {
            mf.userid   = "-1";
            mf.loidMain = "-1";
            
            mf.init();
            
            e.printStackTrace();
        }

        getContentPane().add( mf.getContentPane() );
        
        // changeLanguage();
    }
    
    //just with debug purposes!
    public void changeLanguage()
    {
        try
        {
            Thread tr = new Thread( new Runnable()
            {
                public void run()
                {
                    try
                    {
                        Thread.sleep( 10000 );
                        LanguageManager.getInstance().set( new Locale( "es" ) );
                        LanguageManager.getInstance().refresh();
                        
                        Thread.sleep( 10000 );
                        LanguageManager.getInstance().set( Locale.ENGLISH );
                        LanguageManager.getInstance().refresh();
                        
                        Thread.sleep( 10000 );
                        LanguageManager.getInstance().set( Locale.GERMAN );
                        LanguageManager.getInstance().refresh();
                        
                    }
                    catch ( Exception e )
                    {
                    }
                }
            });
            
            tr.start();
        }
        catch ( Exception e )
        {
            // TODO: handle exception
        }
    }
}
